package com.hup.utils.swing.customView.spinner;

import lombok.extern.log4j.Log4j2;

import javax.swing.*;

/**
 * @apiNote 还可以实现DoubleSpinner
 * @author hugan
 * @date 2020/4/6
 */
@Log4j2
public class IntSpinner extends BaseNumSpinner {

    private SpinnerNumberModel model;

    public IntSpinner() {
        super(new SpinnerNumberModel(0, Integer.MIN_VALUE, Integer.MAX_VALUE, 1));
        model = (SpinnerNumberModel) getModel();
    }

    //idea的ui设计器的界面,只支持基础数据类型的数字set/get
    public void setMin(int v) {
        model.setMinimum(v);
    }

    public int getMin() {
        return (int) model.getMinimum();
    }

    public void setMax(int v) {
        model.setMaximum(v);
    }

    public int getMax() {
        return (int) model.getMaximum();
    }

    public void setStep(int step) {
        model.setStepSize(step);
    }

    public int getStep() {
        return (int) model.getStepSize();
    }

    public void setIntValue(int v) {
        setValue(v);
    }

    public int getIntValue() {
        return (int) getValue();
    }

}
